package cn.tedu.submarine;

import javax.swing.*;

/**
 * 静态图片类
 * 1、该类使用的静态图片，要创建对应的文件夹存放图片，点项目名右键new一个Directory文件夹，命名为img用于存放图片
 * 2、复制课前资料潜艇游戏图片粘贴到img文件夹中
 * 任务：
 * 设计Images图片类，设计战舰图片、侦察潜艇图片、鱼雷潜艇图片、水雷潜艇图片、水雷图片、深水炸弹图片、海洋图片、游戏结束图片，
 * 并在静态块中赋值，设计main方法测试图片是否读取成功
 */
public class Images {
    public static ImageIcon sea;//海洋
    public static ImageIcon gameover;//游戏结束
    public static ImageIcon battleship;//战舰
    public static ImageIcon obsersubm;
    public static ImageIcon torpesubm;
    public static ImageIcon minesubm;
    public static ImageIcon mine;
    public static ImageIcon bomb;//炸弹

    /**
     * 1、使用静态代码块初始化静态图片
     * 2、加载类时同时加载，只加载一次
     * 3、读取img下的sea.png到变量sea中
     */
    static {
        sea = new ImageIcon("mysubmarine/img/sea.png");
        gameover = new ImageIcon("mysubmarine/img/gameover.png");
        battleship = new ImageIcon("mysubmarine/img/battleship.png");
        obsersubm = new ImageIcon("mysubmarine/img/obsersubm.png");
        torpesubm = new ImageIcon("mysubmarine/img/torpesubm.png");
        minesubm = new ImageIcon("mysubmarine/img/minesubm.png");
        mine = new ImageIcon("mysubmarine/img/mine.png");
        bomb = new ImageIcon("mysubmarine/img/bomb.png");
    }

    /**
     * 测试图片是否加载成功
     * 输出返回8表示图片读取成功，返回其余数字表示图片读取失败
     */
    public static void main(String[] args) {
        System.out.println(sea.getImageLoadStatus());//4
        System.out.println(gameover.getImageLoadStatus());
        System.out.println(battleship.getImageLoadStatus());
        System.out.println(obsersubm.getImageLoadStatus());
        System.out.println(torpesubm.getImageLoadStatus());
        System.out.println(minesubm.getImageLoadStatus());
        System.out.println(mine.getImageLoadStatus());
        System.out.println(bomb.getImageLoadStatus());
    }


}
